#ifndef LOGINDIALOG_H
#define LOGINDIALOG_H

#include <MainWindow.h>
#include <QDialog>
#include"global.h"
#include "registerdialog.h"

namespace Ui {
class LogInDialog;
}

class LogInDialog : public QDialog
{
    Q_OBJECT

public:
    explicit LogInDialog(QWidget *parent = nullptr);
    ~LogInDialog();

private:
     void showTip(const QString& test, bool isOk);
     void initHandlers();

 protected:
     void mousePressEvent(QMouseEvent *event) override;
     void mouseMoveEvent(QMouseEvent *event) override;
     void keyPressEvent(QKeyEvent *event) override;

 private slots:
    void on_registerBtn_clicked();
    void on_logInBtn_clicked();
    void slot_login_mod_finish(QByteArray, ReqId, ErrorCodes);
    void on_pushButton_clicked();

signals:
    void sig_logIn_tcp(ServerInfo);

private:
    Ui::LogInDialog *ui;
    QPoint whereIsMouse; // 鼠标点击的起始位置
    MainWindow *parentWindow;

    RegisterDialog *r{nullptr};
    std::map<ReqId, std::function<void(const QJsonObject&)>> _handlers{};
    QString _token{""};
    int _uid{0};
};

#endif // LOGINDIALOG_H
